ImageGear Professional v18.4 > User Guide > Using ImageGear > Optical Character Recognition > Using Auto-Redact > Regular Expressions > Character Classes > Square Bracket Character Classes |
These are the more versatile, but also the more verbose option. It allows you to specify a range of characters to include or exclude. For example, "[A-Za-z]" matches any single upper or lowercase letter character in the Latin character set. And, "[aeiouy]" matches any of the vowel characters.
When two characters are separated by the dash "-" character, it implies the full range of characters between the two inclusive characters in the collating sequence. So, "[0-9]" will match any decimal digit.
To match the dash "-" character, use "[.-.]".
Putting the caret ("^") character after the opening square bracket implies that at this position any character should match, other than those in the brackets. In other words, exclude the specified characters or range of characters. So, "[^aeiouy]" should match any consonant and "[^0-9]" should match any non-Latin digit character.
There are also built-in character classes that can be incorporated within the brackets. These are recommended because their use remains standard, even if for some reason the standard character values changes. Their syntax is "[[:class:]]" or "[^[:class:]]". A few useful classes are: